package com.metaera.app.controller.view;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.metaera.app.R;
import com.metaera.app.controller.view.core.IPaginationView;
import com.metaera.app.data.model.NoticeListResponse;
import com.metaera.app.ui.activities.NotifyDetailsActivity;

import java.util.List;

public class MineNoticeView implements IPaginationView<NoticeListResponse> {

    private final ViewGroup mViewGroup;
    private final TextView  mTvNoticeTitle;


    public MineNoticeView(ViewGroup viewGroup) {
        mViewGroup = viewGroup;
        mTvNoticeTitle = viewGroup.findViewById(R.id.tv_notice_title);
    }

    @Override
    public void renderRefresh(List<NoticeListResponse> refreshData) {
        if (!refreshData.isEmpty()) {
            Context context = mViewGroup.getContext();
            String desc = refreshData.get(0).getDesc();
            String title = refreshData.get(0).getTitle();

            mViewGroup.setVisibility(View.VISIBLE);
            mTvNoticeTitle.setText(title);

            mViewGroup.setOnClickListener(v -> context.startActivity(
                    NotifyDetailsActivity.newIntent(context, title, desc)));
        }
    }

    @Override
    public void renderLoadMore(List<NoticeListResponse> loadMoreData) {

    }

    @Override
    public void renderNoMore() {

    }

}
